package mediatheque.model;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;

public class CdromModel extends DocumentModel {
	
	private static final long serialVersionUID = -2434634628679497463L;
	private String marque;
	
	private static int NOMBRE_CDROM = 0;
	
	public CdromModel() {
		this("N/A", "N/A", "N/A", true, null, "N/A");
	}

	public CdromModel(String nom, String etat, String description, boolean empruntable,
			ArrayList<String> listeTheme, String marque) {
		super("CDRom", nom, etat, description, empruntable, listeTheme);

		this.marque = marque;

		NOMBRE_CDROM++;
		this.setIdentifiant(genererIdentifiant());
	}
	
	private String genererIdentifiant() {
		return "CD-" + NOMBRE_CDROM;
	}

	public String getMarque() {
		return marque;
	}
	
	public void setMarque(String marque) {
		this.marque = marque;
	}
	

	private void writeObject(ObjectOutputStream oos) throws IOException {
		oos.defaultWriteObject();
		oos.writeObject(new Integer(NOMBRE_CDROM));
	}

	private void readObject(ObjectInputStream ois)
			throws ClassNotFoundException, IOException {
		ois.defaultReadObject();
		NOMBRE_CDROM = (Integer) ois.readObject();
	}

}
